using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(menuName = "Data/State/Player/PlayerJump", fileName = "PlayerJump")]
public class PlayerState_Jump : PlayerState
{
    [SerializeField] private float playerJumpSpeed;
    [SerializeField] private float playerJumpMoveSpeed;
    //
    public override void Enter()
    {
        base.Enter();
        AudioManager.Instance.PlayAudioSourceSFX(AudioSFXPath.PLAYER_JUMP, stateMachine.gameObject);
        playerControl.SetVelocityY(playerJumpSpeed);
    }
    
    //
    public override void Exit()
    {
        base.Exit();
    }
    
    //
    public override void LogicUpdate()
    {
        base.LogicUpdate();
        if ((my_Body2D.velocity.y < 0 || playerInput.isInputStopJump) && !playerDetection.GetIsGround)
            stateMachine.SwitchState(stateMachine.stateTable[typeof(PlayerState_Fall)]);
        if(!playerDetection.GetIsGround && playerDetection.IsCanAirJumo && playerInput.isInputJump)
            stateMachine.SwitchState(stateMachine.stateTable[typeof(PlayerState_AirJump)]);
        // 状态
        if(playerStatusInformation.IsFly)
            stateMachine.SwitchState(stateMachine.stateTable[typeof(PlayerState_Fly)]);
        if(playerStatusInformation.PlayerIsHit)
            stateMachine.SwitchState(stateMachine.stateTable[typeof(PlayerState_Hit)]);
        if(playerStatusInformation.GetPlayerIsDeath)
            stateMachine.SwitchState(stateMachine.stateTable[typeof(PlayerState_Death)]);
    }
    
    //
    public override void PhysicalUpdate()
    {
        base.PhysicalUpdate();
        animator.SetFloat("Horizontal", playerInput.axesX);
        playerControl.SetVelocityX(playerJumpMoveSpeed);
    }
}
